#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, hour, minute,hour1,min1,i;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		scanf("%d:%d", &hour1, &min1);
		hour = 13, minute = 15;
		hour += hour1;
		minute += min1;
		while (minute >= 60) { minute -= 60; hour++; }
		while (hour >= 24) { hour -= 24; }
		cout << hour << ":" << minute << endl;
	}
	return 0;
}